clear all
use "Data\W5 (Finaldata Post-Imputation).dta"

factortest q58a q62a

factortest q59a q64a q65a q66a q67a q151a q155a

factortest q60a q149a q150a q154a


*********This is the result of the KMO and Bartlett Test based on file W5(Finaldata Post-Imputation) to ensure that it is feasible for us to use PCA in the data set after imputation. Since the factortest command cannot output the result we want directly, we manually construct file tableA2 by putdocx according to the output result in Results Window of stata.****
putdocx begin
putdocx paragraph, style(Heading1)
putdocx paragraph, font("Times New Roman", 12, black)
putdocx text ("Table A2 The Results of the KMO and Bartlett Test") 
putdocx table mytable = (13, 3)

putdocx table mytable(1, 1) = ("Variable"), font("Times New Roman")  
putdocx table mytable(1, 2) = ("Indicator"), font("Times New Roman")  
putdocx table mytable(1, 3) = ("Outcome"), font("Times New Roman")  

putdocx table mytable(2, 1) = ("Family Values"), font("Times New Roman")  
putdocx table mytable(2, 2) = ("KMO Values"), font("Times New Roman")  
putdocx table mytable(2, 3) = (0.500)   , font("Times New Roman")

putdocx table mytable(3, 1) = ("Family Values"), font("Times New Roman")  
putdocx table mytable(3, 2) = ("Chi-square"), font("Times New Roman")  
putdocx table mytable(3, 3) = (358.470)   , font("Times New Roman")

putdocx table mytable(4, 1) = ("Family Values"), font("Times New Roman")  
putdocx table mytable(4, 2) = ("Degrees of freedom"), font("Times New Roman")  
putdocx table mytable(4, 3) = (1)   , font("Times New Roman")

putdocx table mytable(5, 1) = ("Family Values"), font("Times New Roman")  
putdocx table mytable(5, 2) = ("p-value"), font("Times New Roman")  
putdocx table mytable(5, 3) = ("<0.000")   , font("Times New Roman")




putdocx table mytable(6, 1) = ("Social Values"), font("Times New Roman")  
putdocx table mytable(6, 2) = ("KMO Values"), font("Times New Roman")  
putdocx table mytable(6, 3) = (0.788)   , font("Times New Roman")

putdocx table mytable(7, 1) = ("Social Values"), font("Times New Roman")  
putdocx table mytable(7, 2) = ("Chi-square"), font("Times New Roman")  
putdocx table mytable(7, 3) = (14756.757)   , font("Times New Roman")

putdocx table mytable(8, 1) = ("Social Values"), font("Times New Roman")  
putdocx table mytable(8, 2) = ("Degrees of freedom"), font("Times New Roman")  
putdocx table mytable(8, 3) = (21)   , font("Times New Roman")

putdocx table mytable(9, 1) = ("Social Values"), font("Times New Roman")  
putdocx table mytable(9, 2) = ("p-value"), font("Times New Roman")  
putdocx table mytable(9, 3) = ("<0.000")   , font("Times New Roman")




putdocx table mytable(10, 1) = ("Political Values"), font("Times New Roman")  
putdocx table mytable(10, 2) = ("KMO Values"), font("Times New Roman")  
putdocx table mytable(10, 3) = (0.727)   , font("Times New Roman")

putdocx table mytable(11, 1) = ("Political Values"), font("Times New Roman")  
putdocx table mytable(11, 2) = ("Chi-square"), font("Times New Roman")  
putdocx table mytable(11, 3) = (8524.433)   , font("Times New Roman")

putdocx table mytable(12, 1) = ("Political Values"), font("Times New Roman")  
putdocx table mytable(12, 2) = ("Degrees of freedom"), font("Times New Roman")  
putdocx table mytable(12, 3) = (6)   , font("Times New Roman")

putdocx table mytable(13, 1) = ("Political Values"), font("Times New Roman")  
putdocx table mytable(13, 2) = ("p-value"), font("Times New Roman")  
putdocx table mytable(13, 3) = ("<0.000")   , font("Times New Roman")

putdocx save "Results/Tables/Table A2 The Results of the KMO and Bartlett Test", replace 